﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Castle.Windsor;
using Castle.Windsor.Configuration.Interpreters;
using Castle.Core.Resource;
using log4net;

namespace $UIProjectName$
{
    static class Program
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(Program));
        private static IWindsorContainer _container;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            log.Info("Application started");

            // ----------------------------
            // IoC container initialisation
            // ----------------------------
            _container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));

            log.Info("Ioc container initialized");

            System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
            System.Windows.Forms.Application.Run(new Form1());
        }

        static void Application_ApplicationExit(object sender, EventArgs e)
        {
            _container.Dispose();
        }
    }
}
